<template>
  <div class="device container">
    <dashboard
      :operation-list="operationList"
      @change-device-detail="getDashboardMsg"
    ></dashboard>
  </div>
</template>

<script>
import Dashboard from "@/views/homePage/dashboard/Dashboard";

export default {
  name: "Device",
  components: {
    Dashboard
  },
  data() {
    return {
      operationList: [],
      breadcrumbList: [
        {
          title: "项目管理",
        },
        // {
        //   title: "设备管理",
        //   path: "/news"
        // },
        {
          title: "项目管理",
        },
      ],
      deviceDetail: {
        deviceTotalNum: 0,
        deviceRunTotalNum: 0,
        deviceFaultTotalNum: 0,
        deviceStopTotalNum: 0,
        deviceUnknowTotalNum: 0,
      },
    };
  },
  created() {
    this.getOperationList();
  },
  activated() {
  },
  methods: {
    getOperationList() {
      this.$store.state.permissionList.forEach(item => {
          const [itemName] = item.permission.split(":");
          if (itemName === "project") {
              this.operationList = item.list.map(listItem => {
                  return listItem.permission.split(":")[1];
              });
          }
      });
      this.$store.state.permissionList.some((item) => {
        const [itemName] = item.permission.split(":");
        if (itemName === "businessData") {
            if(item.permission === "businessData:view"){
                this.operationList.push("businessData:view");
                return true;
            }else{
                return false;
            }
        }
      });
    },
    getDashboardMsg() {
      this.deviceDetail = {
            deviceTotalNum: 0,
            deviceRunTotalNum: 0,
            deviceFaultTotalNum: 0,
            deviceStopTotalNum: 0,
            deviceUnknowTotalNum: 0,
          };
    },
  },
  beforeRouteLeave(to, from, next) {
        this.$bus.$emit('clearSearchParams')
        next()
  },
};
</script>

<style lang="sass" scoped></style>
